package com.hnzq.cloud.controller;


import com.hnzq.cloud.model.Result;
import com.hnzq.cloud.param.AddFreGoodsFlagParam;
import com.hnzq.cloud.param.DeleteFreGoodsFlagsParam;
import com.hnzq.cloud.param.UpdateFreGoodsFlagsParam;
import com.hnzq.cloud.service.FreGoodsFlagService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jams
 * @since 2022-02-06
 */
@RestController
@RequestMapping("freGoodsFlag")
public class FreGoodsFlagController {

    @Resource
    private FreGoodsFlagService freGoodsFlagService;

    @PostMapping("addFreGoodsFlag")
    public Result addFreGoodsFlag(@RequestBody AddFreGoodsFlagParam addFreGoodsFlagParam){
        Boolean bool = freGoodsFlagService.addFreGoodsFlag(addFreGoodsFlagParam);
        if (bool){
            return Result.newInstance().setMessage("新增成功");
        }else {
            return Result.newInstance().setMessage("新增失败").setCode(144);
        }
    }

    @DeleteMapping("deleteFreGoodsFlags")
    public Result deleteFreGoodsFlags(@RequestBody DeleteFreGoodsFlagsParam deleteFreGoodsFlagsParam){
        Boolean bool = freGoodsFlagService.deleteFreGoodsFlags(deleteFreGoodsFlagsParam);
        if (bool){
            return Result.newInstance().setMessage("删除成功");
        }else {
            return Result.newInstance().setMessage("删除失败").setCode(144);
        }
    }

    @PutMapping("updateFreGoodsFlags")
    public Result updateFreGoodsFlags(@RequestBody UpdateFreGoodsFlagsParam updateFreGoodsFlagsParam){
        Boolean bool = freGoodsFlagService.updateFreGoodsFlags(updateFreGoodsFlagsParam);
        if (bool){
            return Result.newInstance().setMessage("修改成功");
        }else {
            return Result.newInstance().setMessage("修改删除失败").setCode(144);
        }
    }
}

